package com.santu.edu.supporter.biz.order.kd.controller;

import com.santu.edu.supporter.biz.order.kd.pojo.dto.KdOrderInfoDTO;
import com.santu.edu.supporter.biz.order.kd.pojo.params.KdOrderAddParam;
import com.santu.edu.supporter.biz.order.kd.pojo.params.KdOrderUpdateParam;
import com.santu.edu.supporter.biz.order.kd.pojo.vo.KdOrderVO;
import com.santu.edu.supporter.biz.order.kd.service.KuaidiService;
import com.santu.edu.supporter.biz.pay.pojo.dto.WxChatPayDTO;
import com.santu.edu.supporter.util.PageData;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.annotations.Param;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;

/**
 * @author luoyaoqi
 * @createTime 2024/2/21
 * @description
 */
@RestController
@Validated
@RequiredArgsConstructor
@RequestMapping("order/kd")
public class KuaidiController {

    private final KuaidiService kuaidiService;

    @PostMapping("add")
    public WxChatPayDTO addOrder(@RequestBody @Valid KdOrderAddParam addParam) {
        return kuaidiService.addOrder(addParam);
    }

    @GetMapping("get/pay/by/id")
    public WxChatPayDTO getPayInfoById(@NotBlank(message = "orderId不能为空")String orderId) {
        return kuaidiService.getPayInfoById(orderId);
    }

    @PostMapping("update/address")
    public Boolean updateOrder(@RequestBody @Valid KdOrderUpdateParam updateParam) {
        return kuaidiService.updateOrder(updateParam);
    }

    @PostMapping("cancel")
    public Boolean cancelOrder(@NotBlank(message = "orderId不能为空") String orderId) {
        return kuaidiService.cancelOrder(orderId);
    }

    @PostMapping("good/complete")
    public Boolean goodComplete(@NotBlank(message = "orderId不能为空") String orderId) {
        return kuaidiService.goodComplete(orderId);
    }

    @PostMapping("complete")
    public Boolean orderComplete(@NotBlank(message = "orderId不能为空") String orderId) {
        return kuaidiService.orderComplete(orderId);
    }


    @GetMapping("get/by/orderCode")
    public PageData<KdOrderInfoDTO> getBuildingsList(Integer orderType,
                                                     @RequestParam(defaultValue = "1") int page,
                                                     @RequestParam(defaultValue = "20") int size) {
        return kuaidiService.getOrderList(orderType, page, size);
    }
}
